import ComponentConfiguration from "@site/src/pages/components-explorer/_components/ComponentConfiguration";
import ComponentHeader from "@site/src/pages/components-explorer/_components/ComponentHeader";
import ComponentTroubleshooting from "@site/src/pages/components-explorer/_components/ComponentTroubleshooting/index.mdx";
import ImageClassification from "@site/src/pages/components-explorer/_domains/image_classification/index.mdx";
import ObjectDetector from "@site/src/pages/components-explorer/_domains/object_detector/index.mdx";

import ComponentMetadata from "./_meta";
import config from "./config.json";

<ComponentHeader meta={ComponentMetadata} />

The Coral EdgeTPU provides fast, efficient, private and offline AI inferencing capabilities in multiple form factors, such as a USB accessory or a PCIe module.

:::tip

The `edgetpu` component can also run on the CPU with compatible Tensorflow Lite models.

:::

## Configuration

<details>
  <summary>Configuration example</summary>

```yaml title="/config/config.yaml"
edgetpu:
  object_detector:
    cameras:
      camera_one:
        fps: 1
        labels:
          - label: person
            confidence: 0.8
          - label: cat
            confidence: 0.8
      camera_two:
        fps: 1
        scan_on_motion_only: false
        labels:
          - label: dog
            confidence: 0.8
            trigger_event_recording: false
  image_classification:
    device: cpu
    cameras:
      camera_two:
    labels:
      - dog
```

</details>

<ComponentConfiguration config={config} />

<ObjectDetector
  meta={ComponentMetadata}
  labelPath="/detectors/models/edgetpu/labels.txt"
/>

### Pre-trained models

The included models are placed inside the `/detectors/models/edgetpu` folder.

There are three models:

- SSD MobileNet V2
- EfficientDet-Lite3
- SSDLite MobileDet

The default model is EfficientDet-Lite3 because it features higher precision than the others, with a slightly higher latency.

More information on these models, as well as more object detector models can be found on the [coral.ai website](https://coral.ai/models/object-detection/)

<ImageClassification />

### Pre-trained models

The included model is MobileNet V3.
It is placed inside the `/classifiers/models/edgetpu` folder.
It was chosen because it has high accuracy and low latency.

More image classification models can be found on the [coral.ai website](https://coral.ai/models/image-classification/)

There you will also find information to help you understand if you might want to switch to another model.

## Using multiple Coral EdgeTPU devices

If you have multiple Coral EdgeTPU devices, you can specify which devices to use by setting the `device` parameter in the configuration.

This example shows how to use two Coral EdgeTPU (one USB and one PCIe) devices with the `object_detector` component:

```yaml title="/config/config.yaml"
edgetpu:
  object_detector:
    // highlight-start
    device:
      - usb
      - pci
    // highlight-end
    cameras:
      camera_one:
        fps: 1
        labels:
          - label: person
            confidence: 0.8
          - label: cat
            confidence: 0.8
      camera_two:
        fps: 1
        scan_on_motion_only: false
        labels:
          - label: dog
            confidence: 0.8
            trigger_event_recording: false
```

The load will then be balanced between the two devices.

:::info

Note that the model must be compatible with all device types used.

:::

<ComponentTroubleshooting meta={ComponentMetadata} />
